<?php
/**
 * sdPHP
 * @author     码农<8044023@qq.com>
 * @copyright  sdPHP
 * @license    https://gitee.com/cq8044023/sdphp
 */
namespace sdphp\lib;
class Utils{
    /**
     * 断点调试
     */
    public static function breakpoint(){
        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
        print_r($backtrace);
        print_r("断点中任意键继续:");
        shell_read();
    }
    public static function isDarwin(){
        if (PHP_OS == "Darwin") {
            return true;
        } else {
            return false;
        }
    }
    /**
     * @param string $dev
     * @return string
     */
    public static function getServerIp($dev = 'eth0'){
        return exec("ip -4 addr show $dev | grep inet | awk '{print $2}' | cut -d / -f 1");
    }
    public static function getConfig(){
        return Config::getConfig();
    }
    public static function getServerName(){
        return self::getConfig()["ServerName"];
    }
    /**
     * 去除数组不要的元素
     * @param unknown $arr
     * @param unknown $unarrkey  */
    public static function unArray($arr,$unarrkey){
        $data=array();
        foreach ($arr as $k=>$v){
            if (!in_array($k, $unarrkey)){
                $data[$k]=$v;
            }
        }
        return $data;
    }
}